package com.chencs.app.model.service;

import com.chencs.app.model.mapper.AppModelMapper;
import com.chencs.vo.biz.model.ModeBlockModel;
import com.chencs.vo.biz.model.ModeModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by fangzehua on 2017/7/11.
 */

@Service
public class AppModelService {

    @Autowired
    private AppModelMapper appModelMapper;


    public  List<ModeModel> slideAdver(){

        List<ModeModel> list = appModelMapper.slideAdver();
        if(!list.isEmpty()){
            for(ModeModel s:list){
                s.setModeBlockModel(appModelMapper.findModeBlockByMid(s.getId()));
            }
        }

        return list;
    }


    public List<ModeModel> guide(){
        List<ModeModel> list = appModelMapper.guide();
        if(!list.isEmpty()){
            for(ModeModel s:list){
                s.setModeBlockModel(appModelMapper.findModeBlockByMid(s.getId()));
            }
        }
        return list;
    }

    public List<ModeModel> guideImage(){

        List<ModeModel> list = appModelMapper.guideImage();
        if(!list.isEmpty()){
            for(ModeModel s:list){
                s.setModeBlockModel(appModelMapper.findModeBlockByMid(s.getId()));
            }
        }
        return list;
    }


    public ModeModel getWelcomeAd(){

        ModeModel modeModel = appModelMapper.getWelcomeAd();
        if(modeModel != null){
            modeModel.setModeBlockModel(appModelMapper.findModeBlockByMid(modeModel.getId()));
        }

        return  modeModel;
    }

    public ModeModel getPopupAd(){

        ModeModel modeModel = appModelMapper.getPopupAd();
        if(modeModel != null){
            modeModel.setModeBlockModel(appModelMapper.findModeBlockByMid(modeModel.getId()));
        }
        return  modeModel;
    }



}
